Skip to content

Conversation

@Rajdeepc
Copy link
Contributor

Description

Comprehensive documentation rewrite for sp-truncated with full API reference, accessibility guidelines, usage patterns, and practical examples across multiple component contexts.

Added sp-truncated to bundle/elements.ts to ensure proper component registration and CSS rendering in documentation demo blocks.

Motivation and context

Related issue(s)

  • fixes SWC-431

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result
  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

@Rajdeepc Rajdeepc self-assigned this Oct 28, 2025
@Rajdeepc Rajdeepc requested a review from a team as a code owner October 28, 2025 13:00
@Rajdeepc Rajdeepc added a11y Issues or PRs related to accessibility Documentation Issues or PRs involving changes to documentation or documentation website Status: Ready for review PR ready for review or re-review. labels Oct 28, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2025

⚠️ No Changeset found

Latest commit: caefec6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2025

📚 Branch Preview

🔍 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5839

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@github-actions
Copy link
Contributor

Tachometer results

Currently, no packages are changed by this PR...

@Rajdeepc Rajdeepc marked this pull request as draft October 28, 2025 13:09
@Rajdeepc Rajdeepc added Status: WIP PR is a work in progress or draft and removed Status: Ready for review PR ready for review or re-review. labels Oct 28, 2025
@coveralls
Copy link
Collaborator

coveralls commented Oct 28, 2025

Pull Request Test Coverage Report for Build 18939955006

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 97.964%

Totals Coverage Status
Change from base Build 18885025935: 0.0%
Covered Lines: 34259
Relevant Lines: 34788

💛 - Coveralls

@Rajdeepc
Copy link
Contributor Author

Known issue: sp-tooltip is getting cut off due to max-width constraint for long words. Will be tacked in SWC-1331

@Rajdeepc Rajdeepc marked this pull request as ready for review October 30, 2025 12:03
@Rajdeepc Rajdeepc added Status: Ready for review PR ready for review or re-review. and removed Status: WIP PR is a work in progress or draft labels Oct 30, 2025
Copy link
Contributor

@TarunAdobe TarunAdobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I only have a couple of questions/suggestions.
Also I noticed that the API tab for truncated is all empty and I wonder if that's an easy fix or should we address that separately?

@Rajdeepc
Copy link
Contributor Author

Looks good. I only have a couple of questions/suggestions. Also I noticed that the API tab for truncated is all empty and I wonder if that's an easy fix or should we address that separately?

Yes in our component generation template we are explicitly checking for public properties to show in the API tab. For me this is too restrictive. When there is no modifier, it infers as privacy-> undefined. We can change the logic to place everything which is not private. Let's take this in a separate PR.

return member?.privacy !== 'private';

Copy link
Contributor

@blunteshwar blunteshwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

Copy link
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding so many examples. In doing so I was able to test this and uncover more questions and issues. Take a look at what I have uncovered and decide which observations should be filed as issues, and which issues should be noted as warnings in this documentation.

Comment on lines +81 to +83
<sp-truncated>
ThisIsAVeryLongWordWithoutAnySpacesThatShouldBeTruncated
</sp-truncated>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example isn't working on the docs page as the tooltip does not show the entire content.

Comment on lines +95 to +101
<sp-truncated>
This is the inline content that gets truncated
<span slot="overflow">
This custom overflow content will appear in the tooltip with any
additional information or formatting you need.
</span>
</sp-truncated>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed in the examples that only This is the inline content that gets is displayed and in the tooltip This custom overflow content will appear in the tooltip with any additional information or formatting you need gets displayed, which means, neither the truncated text nor the tooltip show the word truncated (ironic).

Should everything before the overflow be displayed, i.e This is the inline content that gets truncated? Or is this working as designed?

If the latter is true, we should warn consumers that setting the overflow might cause some words to be neither visible in the truncated line nor the tooltip.

Copy link
Contributor

@caseyisonit caseyisonit Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we even include content in an overflowed slot that isnt the actual text? im needing a use case to understand how and when this should be used in product. its feeling like a dark UX pattern.


#### Custom success message

When text is copied to the clipboard, a custom success message can be displayed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried copying the text, and while I got the success message, when I pasted I noticed the copy wasn't the full text.

I didn't realize that the act of clicking the div would copy the whole thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again this feels like a dark pattern, does this mean that anything wrapped in a truncated is keyboard navigable? how would this functionality work for now mouse users? what visual queue are we providing that its copyable?

Comment on lines +164 to +168
<div
style="width: 250px; border: 1px solid var(--spectrum-gray-300); padding: 8px; border-radius: 4px;"
>
<sp-truncated>[email protected]</sp-truncated>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a field instead of a div? Field labels should only be used with interactive elements, such as form fields.

Comment on lines +182 to +184
<sp-truncated>
very.long.username.that.exceeds.the.available.width
</sp-truncated>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltip here is also not displaying the full content.

Comment on lines +204 to +210
**Important accessibility note:** The click handler on the truncated text does not include keyboard event handlers (`/* eslint-disable lit-a11y/click-events-have-key-events */`). This is a known limitation. Users who rely on keyboard navigation will need to use the tooltip hover interaction to view the full content, but cannot copy it via keyboard alone.

#### Screen readers

Screen readers will announce the visible truncated text. When the tooltip appears on hover, screen readers will announce the full content if it differs from the visible text.

For custom overflow content, ensure that the slotted content is semantically meaningful and properly structured for screen readers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Since the sp-truncated does not receive keyboard focus, a keyboard user will never be able to tooltip hover.
  • Screenreader users--who are very often but not always keyboard users---will hear the full content without the tooltip.
  • Not all keyboard users are screenreader users, so this is an accessibility bug.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a very interesting thread in the a11y channel on slack specifically about truncation and how its actually an inaccessible pattern as a whole. we might want to bring this up in one of our team meetings

@caseyisonit
Copy link
Contributor

Looks good. I only have a couple of questions/suggestions. Also I noticed that the API tab for truncated is all empty and I wonder if that's an easy fix or should we address that separately?

Yes in our component generation template we are explicitly checking for public properties to show in the API tab. For me this is too restrictive. When there is no modifier, it infers as privacy-> undefined. We can change the logic to place everything which is not private. Let's take this in a separate PR.

return member?.privacy !== 'private';

I believe we should require every property has a modifier instead of loosing the API table generation. we should be intentional about our properties

@caseyisonit
Copy link
Contributor

I have major accessibility concerns with this component that we need to discuss as a team.

For this specific docs PR:

  • I am seeing correct copy to clipboard.
  • I am seeing INCORRECT rendering of tooltip container on several examples when hovering.
Screenshot 2025-11-10 at 11 05 51 AM Screenshot 2025-11-10 at 11 06 14 AM

Copy link
Contributor

@caseyisonit caseyisonit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left comments

@TarunAdobe
Copy link
Contributor

Looks good. I only have a couple of questions/suggestions. Also I noticed that the API tab for truncated is all empty and I wonder if that's an easy fix or should we address that separately?

Yes in our component generation template we are explicitly checking for public properties to show in the API tab. For me this is too restrictive. When there is no modifier, it infers as privacy-> undefined. We can change the logic to place everything which is not private. Let's take this in a separate PR.

return member?.privacy !== 'private';

Yup! You got this right. I did update it in my last PR so it should be fine now (since this is up to date with main). Everything which is not private should be in the API table for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a11y Issues or PRs related to accessibility Documentation Issues or PRs involving changes to documentation or documentation website Status: Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants